home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / CD-Writing < prev    next >
Text File  |  1997-03-29  |  33KB  |  864 lines

  1.  
  2. CD-Writing mini-HOWTO                      Winfried Trⁿmper <winni@xpilot.org>
  3. ---------------------                      Version 1.8             18 Mar 1997
  4.  
  5.  
  6.  
  7.   I (Winfried Trⁿmper) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  8.   DOCUMENT, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9.   FITNESS FOR A CERTAIN PURPOSE; IN NO EVENT SHALL I BE LIABLE FOR ANY
  10.   SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  11.   RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  12.   CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13.   CONNECTION WITH THE USE OF THIS DOCUMENT.
  14.  
  15.   Short: read and use at your own risk.
  16.  
  17.  
  18.  
  19.   1. Introduction
  20.  
  21.         My first experience with CD Writers was guided by the
  22.         "CD Writer mini-HOWTO" by Matt Cutts <cutts@ms.uky.edu>.
  23.         Thanks Matt!
  24.  
  25.         Although my intention was only to upgrade his document, I
  26.         rewrote it from the scratch after I realized how much changed
  27.         since 1994.
  28.  
  29.  
  30.   1.1. Suggested readings
  31.  
  32.         The "Linux CD-ROM HOWTO" explains everything one should know
  33.         about CD-ROM drives under Linux.
  34.         As a supplement, you may want to take a look at the
  35.         "Linux SCSI HOWTO" and the "Linux Kernel HOWTO".
  36.  
  37.  
  38.   1.2. Terminology ... lasers at maximum ... fire!
  39.  
  40.         "CD-ROM" stands for "Compact Disc Read Only Memory", a storage
  41.         medium utilizing an optical laser to sense microscopic pits on
  42.         a silver shimmering disk. (The silver shimmering comes from an
  43.         aluminized layer which is the carrier.) The pits represent the
  44.         bits of the information (in some way) and are so petite that
  45.         some billions of them fit on the disc. Thus a CD is a
  46.         mass-storage medium.
  47.  
  48.         The Term "CD-R" is a short form of "CD-ROM recordable" and refers
  49.         to a CD that doesn't have those "microscopic pits" on it's
  50.         surface ... thus it's empty.
  51.         Instead of the aluminium layer (silver) it has a special film
  52.         (colored) into which "microscopic pits" can be burned in. This is
  53.         done by giving the laser which normally only senses the pits a
  54.         little bit more power so he burns the pits. This action can only
  55.         be taken _once_ on a CD-R.
  56.  
  57.         This mini-HOWTO deals with the task of writing such a CD-R.
  58.         Welcome on board, captain.
  59.  
  60.  
  61.   1.3. Supported CD-Writers
  62.  
  63.         "Linux" supports CD-writers of the following manufacturers
  64.  
  65.                 Philips, IMS, Kodak, Yamaha, Hewlett-Packard
  66.  
  67.         or compatibles ...
  68.  
  69.         If your hardware isn't supported you can still use Linux
  70.         to create an image of the later CD but then you have to use
  71.         DOS-Software to write the image to the CD-R. [You may wish to
  72.         do so because most DOS-software cannot deal with long
  73.         filenames available in Linux.]
  74.         In this case you can skip all hardware-related sections (those
  75.         about "generic SCSI devices" and "cdwrite").
  76.  
  77.  
  78.   1.4. Supported "features"
  79.  
  80.         Currently the software for burning CDs under Linux does 
  81.         support the following main features:
  82.  
  83.           * RockRidge Extensions
  84.           * "Multisession" CDs and
  85.           * "El Torito" (bootable) CDs.
  86.  
  87.  
  88.   1.5. Mailinglists
  89.  
  90.         If you want to join the development team (with the intention
  91.         to actively _help_ them), send e-mail to
  92.  
  93.                 cdwrite-request@pixar.com
  94.  
  95.         and put the command "subscribe" in body of the message.
  96.  
  97.  
  98.  
  99.   2. Prepare your Linux-box for writing CD-ROMs
  100.  
  101.   2.1. Set up the hardware
  102.  
  103.     (a) Shut down your computer, switch it off and hook CD writer to the
  104.         SCSI-bus. Please note that CD-writers require a SCSI-controller,
  105.         the standard EIDE-Interface of your PC has no ability to drive
  106.         those writers.
  107.  
  108.     (b) Make sure the SCSI-bus is properly terminated and choose a free
  109.         SCSI-ID for the writer. Look at the Linux SCSI-HOWTO if you're
  110.         not sure. If you're completly clueless, ask an expert.
  111.  
  112.     (c) Switch the power on again and check the messages that the BIOS of
  113.         the SCSI-controller prints immediatly after switching the power
  114.         on.
  115.         If it doesn't recognize you writer, go back to step (b).
  116.         You should see a message like
  117.  
  118.  
  119.                 [missing picture; has anyone a screenshot of it?]
  120.  
  121.  
  122.   2.2. A note on writing CDs under Linux
  123.  
  124.         In contrast to other rumors, the Linux-kernel does _not_
  125.         require a patch in order to write to CDs. Although the
  126.         file "drivers/scsi/scsi.c" from the kernel-sources
  127.         contains the lines
  128.  
  129.                   case TYPE_WORM:
  130.                   case TYPE_ROM:
  131.                     SDpnt->writeable = 0;
  132.  
  133.         this does only mean that that CDs and WORMs are not writeable
  134.         through the standard-devices "/dev/sda"-"/dev/sdh" which is ok.
  135.  
  136.         Instead of using these devices the writing of CDs is done
  137.         through the so called "generic SCSI-devices" which permit
  138.         nearly everything - even writing to CDs.
  139.  
  140.  
  141.   2.3. Create "generic devices"
  142.  
  143.         The Linux SCSI-HOWTO says about generic SCSI-devices:
  144.  
  145.                 The Generic SCSI device driver provides an interface
  146.                 for sending SCSI commands to all SCSI devices - disks,
  147.                 tapes, CDROMs, media changer robots, etc.
  148.  
  149.  
  150.         Speaking of the generic devices as "interfaces" means that
  151.         they provide an alternate way of accessing SCSI-hardware than
  152.         through the standard devices.
  153.         It is necassary because Linux does not allow direct hardware access
  154.         through the standard SCSI-devices - everything must pass by the
  155.         kernel first. But the writing-software _requires_ direct access to
  156.         the CD-writer hardware - so there must be an alternate way.
  157.  
  158.         [Note: if there were a standard for driving CD-writers, the
  159.          kernel-developers would have programmed a kernel-module for
  160.          writing to CD-Rs and we wouldn't have to use generic devices.
  161.          But as every manufacturer needs an individual driver for its
  162.          hardware (argh!), this kernel-module would become unhandy and
  163.          bigger than everything you want to be in your kernel.]
  164.  
  165.         As everthing can be done to SCSI-hardware through the generic
  166.         devices they are not fixed to a certain purpose - therefore the
  167.         name "generic".
  168.  
  169.         Goto the "/dev"-directory and check for "generic scsi devices";
  170.         "ls"-command should show "sga"-"sgh":
  171.  
  172.                 bash> cd /dev
  173.                 bash> ls -l sg*
  174.                 crw-------   1 root   sys     21,   0 Jan  1  1970 sga
  175.                 crw-------   1 root   sys     21,   1 Jan  1  1970 sgb
  176.                 crw-------   1 root   sys     21,   2 Jan  1  1970 sgc
  177.                 crw-------   1 root   sys     21,   3 Jan  1  1970 sgd
  178.                 crw-------   1 root   sys     21,   4 Jan  1  1970 sge
  179.                 crw-------   1 root   sys     21,   5 Jan  1  1970 sgf
  180.                 crw-------   1 root   sys     21,   6 Jan  1  1970 sgg
  181.                 crw-------   1 root   sys     21,   7 Jan  1  1970 sgh
  182.  
  183.         If you don't have those device-files then create them by using
  184.         the "/dev/MAKEDEV"-script:
  185.  
  186.                 bash> cd /dev/
  187.                 bash> ./MAKEDEV sg
  188.  
  189.         Now the device-files should show up.
  190.  
  191.  
  192.   2.4. Enable usage of the "generic scsi" and "loopback" devices
  193.  
  194.         The Linux-kernel needs a module that lends it the ability to
  195.         deal with generic scsi devices.
  196.         If your running kernel has this feature, it should be listed
  197.         in the pseudo-file "/proc/devices":
  198.  
  199.                 bash> cat /proc/devices
  200.                 Character devices:
  201.                  1 mem
  202.                  2 pty
  203.                  3 ttyp
  204.                  4 ttyp
  205.                  5 cua
  206.                  7 vcs
  207.                 21 sg          <----- stands for "Scsi Generic device"
  208.                 
  209.                 30 socksys
  210.  
  211.                 Block devices:
  212.                  2 fd
  213.                  7 loop        <----- we even can use the loop-devices
  214.                  8 sd
  215.                 11 sr          <----- stands for "Scsi cd-Rom"
  216.  
  217.  
  218.         Maybe you have to issue the commands "insmod sg", "insmod loop"
  219.         or "insmod sr_mod" to load the modules into the kernel. Check
  220.         again after you've tried this.
  221.  
  222.         If one of them doesn't succeed, you must re-configure your kernel
  223.         and re-compile it.
  224.  
  225.                  bash> cd /usr/src/linux
  226.                  bash> make config
  227.  
  228.                  [..]
  229.                  *
  230.                  * Additional Block Devices
  231.                  *
  232.                  Loopback device support (CONFIG_BLK_DEV_LOOP) [M/n/y/?] M
  233.  
  234.                  [..]
  235.                  *
  236.                  * SCSI support
  237.                  *
  238.                  SCSI support (CONFIG_SCSI) [Y/m/n/?]
  239.                  *
  240.                  * SCSI support type (disk, tape, CD-ROM)
  241.                  *
  242.                  SCSI disk support (CONFIG_BLK_DEV_SD) [Y/m/n/?] Y
  243.                  SCSI tape support (CONFIG_CHR_DEV_ST) [M/n/y/?] M
  244.                  SCSI CD-ROM support (CONFIG_BLK_DEV_SR) [M/n/y/?] M
  245.                  SCSI generic support (CONFIG_CHR_DEV_SG) [M/n/y/?] M
  246.  
  247.                  [..]
  248.                  ISO9660 cdrom filesystem (CONFIG_ISO9660_FS) [Y/m/n/?] M
  249.  
  250.  
  251.         Please note that I omitted the not-so-important questions.
  252.  
  253.  
  254.  
  255.   2.5. Build and install the kernel
  256.  
  257.         If you have questions regarding to this the Linux Kernel-HOWTO
  258.         is the suggested reading. Furthermore your Linux-distribution
  259.         should ship with some documentation about this issue.
  260.  
  261.         [Hint: while re-compiling, you can continue with steps 2.7-2.9]
  262.  
  263.  
  264.  
  265.   2.6. Reboot the computer for the changes to take effect.
  266.  
  267.         Don't panic if the Linux-kernel prints the messages faster than you
  268.         can read them, at least the initialization of SCSI-devices can be
  269.         re-displayed with the command "dmesg":
  270.  
  271.  
  272.         scsi0 : NCR53c{7,8}xx (rel 17)
  273.         scsi : 1 host.
  274.         scsi0 : target 0 accepting period 100ns offset 8 10.00MHz
  275.         scsi0 : setting target 0 to period 100ns offset 8 10.00MHz
  276.  
  277.           Vendor: FUJITSU   Model: M1606S-512        Rev: 6226
  278.           Type:   Direct-Access                      ANSI SCSI
  279.         Detected scsi disk sda at scsi0, channel 0, id 0, lun 0
  280.  
  281.           Vendor: NEC       Model: CD-ROM DRIVE:84   Rev:  1.0a
  282.           Type:   CD-ROM                             ANSI SCSI
  283.         Detected scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0
  284.  
  285.         scsi : detected 1 SCSI disk total.
  286.         SCSI device sda: hdwr sector= 512 bytes. Sectors= 2131992
  287.  
  288.  
  289.         Shown above is only that part of the initialization-messages
  290.         that report the detection of physically present SCSI-devices.
  291.  
  292.  
  293.   2.7. Create "loopback devices"
  294.  
  295.         Goto the "/dev"-directory and check for "loopback devices".
  296.         It's not critical if you don't have those devices, but it's
  297.         convenient if you do (see 3.5).
  298.         If you already have them, the "ls"-command should show
  299.         loop0-loop7:
  300.  
  301.                 bash> cd /dev
  302.                 bash> ls -l loop*
  303.                 brw-rw----   1 root  disk    7,   0 Sep 23 17:15 loop0
  304.                 brw-rw----   1 root  disk    7,   1 Sep 23 17:15 loop1
  305.                 brw-rw----   1 root  disk    7,   2 Sep 23 17:15 loop2
  306.                 brw-rw----   1 root  disk    7,   3 Sep 23 17:15 loop3
  307.                 brw-rw----   1 root  disk    7,   4 Sep 23 17:15 loop4
  308.                 brw-rw----   1 root  disk    7,   5 Sep 23 17:15 loop5
  309.                 brw-rw----   1 root  disk    7,   6 Sep 23 17:15 loop6
  310.                 brw-rw----   1 root  disk    7,   7 Sep 23 17:15 loop7
  311.  
  312.         If you don't have those device-files, then create them by using
  313.         the "/dev/MAKEDEV"-script:
  314.  
  315.                 bash> cd /dev/
  316.                 bash> ./MAKEDEV loop
  317.  
  318.         The last command only succeeds if you have the "loop"-module in
  319.         your kernel (see 2.4 for handling of modules). If "insmod loop"
  320.         does not help, you must wait until the new kernel is properly
  321.         installed.
  322.  
  323.  
  324.   2.8. Get the user-software for burning CDs
  325.  
  326.   2.8.1. Command line utilities
  327.  
  328.         The following packages are essential:
  329.  
  330. ftp://tsx-11.mit.edu/pub/linux/packages/mkisofs/mkisofs-1.10.tar.gz
  331. ftp://sunsite.unc.edu/pub/Linux/utils/disk-management/cdwrite-2.0.tar.gz
  332.  
  333.         Please use the nearest mirrors of these ftp-Servers or download
  334.         them from a CD.
  335.  
  336.         Be absolutly sure you have version 2.0 of "cdwrite". No older
  337.         version and especially no beta-versions will work properly! Don't
  338.         trust the man-page of (old) "mkisofs". The "mkisofs"-package
  339.     contains a old version (1.5) of "cdwrite" that will produce no
  340.     usable result.
  341.  
  342.  
  343.         The Debian-Distribution ships with a patch for release 1.05 of
  344.     "mkisofs" that adds the option '-K' to it (see 3.4); it's
  345.     available from 
  346.  
  347. ftp://ftp.debian.org/pub/debian/rex/source/misc/mkisofs_1.05-3.diff.gz
  348.  
  349.         This patch is only necassary if you want to mount the CD-image
  350.         via the loopback-device (see 3.5.).
  351.  
  352.  
  353.   2.8.2. A graphical user interface (optional)
  354.  
  355.         X-CD-Roast is a graphical frontend (X11) for CD related programs
  356.         like "cdwrite-2.0" and "mkisofs-1.05". It's available from
  357.  
  358. http://www.fh-muenchen.de/home/ze/rz/services/projects/xcdroast/e_overview.html
  359.  
  360.     X-CD-Roast is full X based CD-Writer-Program, and it is the successor
  361.     of the "cdwtools-0.93".
  362.  
  363.  
  364.   3. "If to smoke you turn I shall not cease to fiddle while you burn."
  365.      (Emperor nero about burning his own classic-CDs [AD64]; he
  366.       misunderstand it completly)
  367.  
  368.  
  369.         Usally the writing of a CD under Linux is done in 2 steps:
  370.  
  371.               - packaging the desired software into one big file using
  372.                 the "mkisofs"-utility
  373.  
  374.               - writing the big file to the CD-R with "cdwrite"
  375.  
  376.  
  377.         It also possible to combine the 2 steps into one via a pipe
  378.         but that is discouraged because it's not reliable. See below.
  379.  
  380.  
  381.   3.1. Determine which generic scsi device the writer is attached to
  382.  
  383.         After following all steps of the second chapter your system
  384.         should be able to deal with the task of writing CDs. This
  385.         section can be used as a proof that everything works as
  386.         intended.
  387.  
  388.         Issue the command "dmesg". It should report the messages of
  389.         the Linux-kernel including those printed while booting
  390.         (limitation: only the last 200) and contain some information
  391.         about the CD-Writer connected to the SCSI-bus.
  392.  
  393.         Simple example:
  394.  
  395.               Vendor: YAMAHA  Model: CDR100       Rev: 1.11
  396.               Type:   WORM                        ANSI SCSI revision: 02
  397.             Detected scsi CD-ROM sr1 at scsi0, channel 0, id 3, lun 0
  398.  
  399.  
  400.         This machine has 4 SCSI-devices connected to it (you can't see it
  401.         so I tell you), with SCSI-id's from 0 to 3. The writer is the
  402.         4th physically present SCSI-device and therefore connected to
  403.         "/dev/sgd" (the fourth generic SCSI-device when counting is started
  404.         with "a").
  405.         In this case the command
  406.  
  407.             cdwrite  --eject  --device /dev/sgd
  408.  
  409.  
  410.         opens the tray and is a test if everything is set up properly.
  411.  
  412.  
  413.         A more complicated example:
  414.  
  415.             scsi0 : AdvanSys SCSI 1.5: ISA (240 CDB)
  416.             scsi1 : Adaptec 1542
  417.             scsi : 2 hosts.
  418.  
  419.               Vendor: HP      Model: C4324/C4325  Rev: 1.20
  420.               Type:   CD-ROM                      ANSI SCSI revision: 02
  421.             Detected scsi CD-ROM sr0 at scsi0, channel 0, id 2, lun 0
  422.  
  423.               Vendor: IBM     Model: DPES-31080   Rev: S31Q
  424.               Type:   Direct-Access               ANSI SCSI revision: 02
  425.             Detected scsi disk sda at scsi1, channel 0, id 0, lun 0
  426.  
  427.             scsi : detected 1 SCSI cdrom 1 SCSI disk total.
  428.             SCSI device sda: hdwr sector= 512 bytes.
  429.  
  430.  
  431.         In this example two SCSI-controllers host 1 SCSI-device each.
  432.         What a waste (they are able to host up to 7 devices each). It's
  433.         not my setup so stop asking if I have too much money ...
  434.         Anyway for the purpose of being an overlookable example this
  435.         setup is just excellent. :-)
  436.  
  437.         In the above example the CD-Writer has SCSI-id 2 but it is
  438.         associated with the first generic SCSI-device "/dev/sga" because
  439.         it's the first physically present SCSI-device which Linux has
  440.         detected.
  441.         Hopefully this shows clearly that the SCSI-id of a device has
  442.         nothing to do with the associated generic device.
  443.  
  444.  
  445.         Two questions are left: what happens if you catch the wrong
  446.         device?
  447.         If you neither specify the option "--<MANUFACTURER>" nor write
  448.         any data to the device, usally a warning message is printed and
  449.         nothing bad happens:
  450.  
  451.                 bash> cdwrite  --eject  --device /dev/sgb
  452.  
  453.                 Unknown CD-Writer; if this model is compatible with any
  454.                 supported type, please use the appropriate command line
  455.                 flag.
  456.  
  457.                 Manufacturer:  IBM
  458.                 Model:         DPES-31080
  459.                 Revision:      S31Q
  460.  
  461.  
  462.         In this case the device "/dev/sbg" is a scsi harddisk (from IBM).
  463.  
  464.         If you write data to the wrong device, you overwrite the
  465.         original content of it and probably irrecoverable damage
  466.         your system. Believe me, it already happened to me by accident.
  467.  
  468.         Be careful.
  469.  
  470.  
  471.  
  472.   3.2. Collect software
  473.  
  474.         Usally this takes up longer than one expects. Remember that
  475.         missing files cannot be added once the CD is written. :-)
  476.  
  477.         Also keep in mind that a certain amount of the free space
  478.         of a CD is used for storing the information of the
  479.         iso9660-filesystem (usally a few MB).
  480.  
  481.  
  482.  
  483.   3.3. Storing data on a CD.
  484.  
  485.         The term "iso9660" refers to the format in which data is
  486.         organised on the CD. To be more precise: it's the filesystem on
  487.         the CD.
  488.  
  489.         Of course the appearance of files stored in this format is
  490.         unified by the Linux-kernel as for every other filesystem, too.
  491.         So if you mount a CD into the directory tree, you cannot
  492.         distinguish it's files from other files ... beside the fact
  493.         that they are not writeable ...  even not for root. :-)
  494.         (The mechanism used to unify the appearance of files is called
  495.         "virtual filesystem", short "VFS".)
  496.  
  497.         The features of the iso9660 filesystem are not so rich compared
  498.         to those of the extended-2 filesystem which is normally used
  499.         under Linux. On the other hand, the CD is only writable once and
  500.         some features make no sense anyway.
  501.         The limitations of the iso9660-filesystem are:
  502.  
  503.               - only 8 levels of sub-directories allowed (counted from
  504.                 the top-level directory of the CD)
  505.  
  506.               - maximum length for filenames: 32 characters
  507.  
  508.               - 650 MB capacity
  509.  
  510.  
  511.  
  512.   3.4. Create an iso9660 filesystem
  513.  
  514.         Before any storage medium (e.g. floppy disk, harddisk or CD)
  515.         can be used, it must get a filesystem (DOS speak: get formatted).
  516.         This filesystem is responsible for organising and incorporating
  517.         the files that should be stored on the medium.
  518.  
  519.         Well, the writable CDs are only writable _once_ so if we would
  520.         write an empty filesystem to them they would get formated - but
  521.         remain completely empty forever. :-)
  522.  
  523.         So what we need is a tool that creates the filesystem while
  524.         copying the files to the CD. This tool is called "mkisofs".
  525.         A sample usage looks as follows:
  526.  
  527.  
  528.                  mkisofs  -r -K  -o cd_image   private_collection/
  529.                                  `---------'   `-----------------'
  530.                                       |                |
  531.                         write output to    take directory as "input"
  532.  
  533.  
  534.         The option '-r' sets the permissions of all files to be public
  535.         readable on the CD and enables Rock Ridge extensions. That is
  536.         what one usually wants and use of this option is recommended
  537.         until you know what you're doing (hint: without '-r' the mount-point
  538.         gets the permissions of "private_collection"!).
  539.         The option '-K' fixes a bug in the Linux kernel and prevents the
  540.         last file on the CD from being "destroyed" (not really, but Linux
  541.         can't read it). This option is equivalent to the option '-P' of
  542.         "cdwrite".
  543.         Please see the manual-page of "mkisofs" for details.
  544.  
  545.         "mkisofs" will try to map all filenames to the 8.3-format used
  546.         by DOS to ensure highest possible compatibility. In case of
  547.         naming conflicts (different files have the same 8.3-name),
  548.         numbers are used in the filenames and information about the
  549.         chosen filename is printed via stderr (usually the screen).
  550.  
  551.         DON'T PANIC:
  552.  
  553.                 Under Linux you will never see these 8.3 filenames
  554.                 because Linux makes use of the Rock Ridge extensions
  555.                 which contain the original file-information (permissions,
  556.                 filename, etc.).
  557.  
  558.  
  559.         Now you may wonder why the output of "mkisofs" is not directly
  560.         sent to the writer-device. This has two reasons:
  561.  
  562.             (1) "mkisofs" knows nothing about driving CD-writers (see
  563.                 section 2.3.)
  564.             (2) It would not be reliable (see section 4.)
  565.  
  566.  
  567.         Because the timing of the CD-writer is a critical point, we
  568.         don't feed it directly from "mkisofs" (remember Linux is not
  569.         a real-time operating system and tasks can be timed badly).
  570.         Instead it is recommended to store the output of "mkisofs"
  571.         in a separate file on the harddisk.
  572.         This file is then an 1:1-image of the later CD and is actually
  573.         written to the CD with the tool "cdwrite" in a second step.
  574.  
  575.         The 1:1-image gets stored in a huge file so you need the same
  576.         amount of free disk space that your collected software already
  577.         eats up. That's a drawback.
  578.         One could think of creating an extra partition for that and
  579.         writing the image to that partition instead to a file. I vote
  580.         against such a strategy because if you write to the wrong
  581.         partition (due to a typo), you can lose your complete
  582.         Linux-system.
  583.         Furthermore, it's a waste of disk-space because the CD-image is
  584.         temporary data that can be deleted after writing the CD.
  585.  
  586.  
  587.   3.5. Test the CD-image
  588.  
  589.         Linux has the ability to mount files as if they were
  590.         disk-partitions. This feature is useful to check the directory
  591.         layout of the CD-image is ok.
  592.  
  593.         To mount the file "cd_image" created above on the directory
  594.         "/cdrom", give the command
  595.  
  596.                 mount -t iso9660 -o ro,loop=/dev/loop0 cd_image /cdrom
  597.  
  598.  
  599.         Now you can inspect the files under /cdrom - they appear
  600.         exactly as they were on a "real" CD. To umount the CD-image,
  601.         just say "umount /cdrom". 
  602.         Warning: If you did not use the option "-K" for mkisofs then the
  603.         last file on /cdrom is not fully readable.
  604.  
  605.         Note: some ancient versions of "mount" are not able to deal
  606.               with loopback-devices. If you have such an old version
  607.               of "mount" it is a hint to upgrade your Linux-system.
  608.  
  609.               Several people already suggested to put information
  610.               about how to get the newest mount-utilities into this
  611.               mini-HOWTO. I always refuse this.
  612.               If your Linux-Distribution ships with an ancient "mount":
  613.               report it as a bug.
  614.               If your Linux-Distribution is not easily upgradable:
  615.               report it as a bug.
  616.  
  617.               If I included all the information that is necessary
  618.               to work around bugs in bad designed Linux-Distributions,
  619.               this mini-HOWTO would be a lot bigger and harder to read.
  620.  
  621.  
  622.   3.6. Remarks on the blank CD-Recordable discs
  623.  
  624.         The german computer magazine "c't" has a list of tips regarding
  625.         the blank CDs in their november 1996 issue:
  626.  
  627.               - "no-name" discs are generally not of highest quality
  628.                 and should better not be used
  629.  
  630.               - if a recordable CD is defective, this is likely to
  631.                 apply to the whole batch (if you bought more than one at
  632.                 a time);  maybe you are lucky and can at least use the
  633.                 first 500MB of such CDs ...
  634.  
  635.               - don't touch the CDs at their shimmering side before
  636.                 writing
  637.  
  638.  
  639.  
  640.   3.7. Write the CD-image to a CD
  641.  
  642.         Not much more left to do. Before showing you the last command,
  643.         let me warn you that CD-writers want to be fed with a constant
  644.         stream of data because they have no (or only small) data-buffers.
  645.         So the process of writing the CD-image to the CD mustn't be
  646.         interupted or a corrupt CD will be the result.
  647.  
  648.         To be sure nothing can interupt this process, throw all users
  649.         of the system and unplug the ethernet-cable ...
  650.         Read the "Bastard operator from hell" to learn about the right
  651.         attitude to do so. ;-)
  652.  
  653.  
  654.         If you are mentally prepared, dress up in a black robe, multiply
  655.         the SCSI-id of the CD-writer with it's SCSI-revision and light
  656.         as many candles, speak two verses of the ASR-FAQ and finally type
  657.  
  658.  
  659.             cdwrite  --device /dev/sgd  cd_image
  660.  
  661.  
  662.         Of course you have to replace "/dev/sgd" with the generic
  663.         SCSI-device your writer is connected to.
  664.  
  665.         Please note that no writer can re-position it's laser and can't
  666.         continue at the original spot on the CD when it gets disturbed.
  667.         Therefore any strong vibrations or even a shock will
  668.         completly destroy the CD you are writing.
  669.  
  670.  
  671.   3.8. If something goes wrong ...
  672.  
  673.         ... remember you can still use corrupt CDs as coasters. :-)
  674.  
  675.  
  676.  
  677.  
  678.   4. Frequently asked questions with answers
  679.  
  680.   4.1. "How sensitive is the burning process?"
  681.  
  682.         Answer: that depends on your writer. Modern ones should have a 
  683.         data-buffer of 1MB or such and can live 1-2 seconds without data.
  684.         See the manuals or ask your manufacturer if you want to know
  685.         the details.
  686.         Regardless of the size of those data-buffers you must guarantee
  687.         a constant throughput of 300kb/s or 600kb/s in the long time run.
  688.  
  689.         Disk intensive processes such as updating the "locate"-database
  690.         lower the maximum flow-rate will surely corrupt the CD; you
  691.         better check such processes are not started via "cron", "at" or
  692.         "anacron".
  693.  
  694.         On the other hand, people reported that they compiled a kernel
  695.         while burning a CD without a glitch. Of course you need a _very_
  696.         fast machine for such experiments.
  697.  
  698.  
  699.   4.2. "Has fragmentation a bad impact on the throughput?"
  700.  
  701.         Fragmentation is usally so low that it's impact isn't noticed.
  702.  
  703.         If you're uncertain than look at the messages printed while
  704.         booting, the percentage of fragmentation is reported while
  705.         checking the filesystems. You can check for this value with
  706.         the very dangerous command
  707.  
  708.                 bash> e2fsck -n  /dev/sda5        # '-n' is important!
  709.                 [stuff deleted - ignore any errors]
  710.                 /dev/sda5: 73/12288 files (12.3% non-contiguous)
  711.  
  712.         In this example the fragmentation seems to be very high - but
  713.         there are only 73 very small files on this filesystem (used as
  714.         "/tmp") so the value is _not_ alarming.
  715.  
  716.  
  717.   4.3. "Is it possible to store the CD-image on an UMSDOS-filesystem?"
  718.  
  719.         Yes. The only filesystem that isn't reliable and fast enough
  720.         for writing CDs from is NFS ("network filesystem").
  721.  
  722.         I'm using UMSDOS myself to share the disk-space between Linux
  723.         and DOS/Win on a PC (486/66) dedicated for writing CDs.
  724.  
  725.  
  726.   4.4. "Isn't there some way to get around the iso9660 limitations?"
  727.  
  728.         Yes. You can put any filesystem you like on the CD. But other
  729.         Operating systems than Linux won't be able to deal with this
  730.         CD.
  731.  
  732.         Here goes the recipe:
  733.  
  734.             (a) Create an empty file of 650MB size.
  735.  
  736.                         dd if=/dev/zero of="empty_file" bs=1024k count=650
  737.  
  738.  
  739.             (b) Create an extended-2 filesystem on this file
  740.  
  741.                         bash> /sbin/mke2fs  empty_file 
  742.                         empty_file is not a block special device.
  743.                         Proceed anyway? (y,n) y
  744.  
  745.  
  746.             (c) Mount this empty file through the loopback-devices
  747.  
  748.                         mount -t ext2 -o loop=/dev/loop1 empty_file /mnt
  749.  
  750.  
  751.             (d) Copy files to /mnt and umount it afterwards.
  752.  
  753.             (e) Use "cdwrite" on empty_file as if it were an 
  754.                 iso9660-image. Use '-P' as an option to "cdwrite".
  755.  
  756.  
  757.         If you want to make an entry in /etc/fstab for such a CD, disable
  758.         the checking of it, e.g.:
  759.  
  760.                 /dev/cdrom  /cdrom  ext2  defaults,ro  0 0
  761.  
  762.         The first 0 means "don't include in dumps", the second (=important)
  763.         one means "don't check for errors on startup".
  764.  
  765.  
  766.   4.5. "How to read and write audio CDs?"
  767.  
  768.         Please get the packages "cdda2wav" and "sox", available from
  769.         sunsite and it's mirrors:
  770.  
  771. ftp://sunsite.unc.edu/pub/Linux/apps/sound/cds/cdda2wav0.71.src.tar.gz
  772. ftp://sunsite.unc.edu/pub/Linux/apps/sound/convert/sox-11gamma-cb2.tar.gz
  773.  
  774.         "cdda2wav" enables you to get a specific interval (or a whole
  775.         track) from your audio CD and converts it into a .wav-file.
  776.     "sox" converts the wav-files back into the (audio-CD) cdda-format
  777.         so it can be written to the CD-R using "cdwrite".
  778.  
  779.  
  780.   4.6. "How to probe for SCSI-devices after boot?"
  781.  
  782.     The file "drivers/scsi/scsi.c" contains the information
  783.  
  784.     /*
  785.      * Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
  786.      * with  "0 1 2 3" replaced by your "Host Channel Id Lun".
  787.      * Consider this feature BETA.
  788.      *     CAUTION: This is not for hotplugging your peripherals. As
  789.      *     SCSI was not designed for this you could damage your
  790.      *     hardware !  
  791.      * However perhaps it is legal to switch on an
  792.      * already connected device. It is perhaps not 
  793.      * guaranteed this device doesn't corrupt an ongoing data transfer.
  794.      */
  795.  
  796.  
  797.   4.7. "Is it possible to make a 1:1 copy of a CD?"
  798.  
  799.     Yes. First case: you have a CD-writer and a seperate CD-ROM
  800.     drive. By issuing the command
  801.  
  802.     cdwrite -v -D /dev/sgc --pad -b  `isosize  /dev/scd0` /dev/scd0
  803.  
  804.     you read the data stream from the CD-ROM drive attached as
  805.     /dev/scd0 and write it directly through /dev/sgc to the CD-R.
  806.  
  807.     Second case: you don't have a seperate CD-ROM drive. You have
  808.     to use the writer to read out the CD-ROM in this case:
  809.  
  810.         dd if=/dev/scd0 of=cdimage bs=1c count=`isosize  /dev/scd0`
  811.     
  812.     This command is equivalent to the result of "mkisofs", so you
  813.     should procede as described in chapter 3.
  814.  
  815.  
  816.   5. Credits
  817.  
  818.         Andreas Erdmann <erdmann@zpr.uni-koeln.de>
  819.                 provided the example with the YAMAHA-writer
  820.  
  821.         Art Stone <stone@math.ubc.ca>
  822.                 had the idea to put non-iso9660 filesystems on a CD
  823.  
  824.         Bernhard Gubanka <beg@ipp-garching.mpg.de>
  825.                 noticed the need of a recent version of mount to
  826.                 utilize the loopback device
  827.  
  828.     Brian H. Toby
  829.         polished the wording.
  830.  
  831.         Bruce Perens <bruce@pixar.com>
  832.                 gave information about the cdwrite-mailinglist
  833.  
  834.     Dale Scheetz <dwarf@polaris.net>
  835.         helped improving the section about creating the cdimage.
  836.  
  837.         Edwin H. Kribbs
  838.                 reported that '-K' requires a patch for mkisofs
  839.  
  840.         Gerald C Snyder <gcsnyd@loop.com>
  841.                 tested writing of an ext2 CD-ROM (see 4.4)
  842.  
  843.         Ingo Fischenisch <ingo@mi.uni-koeln.de>
  844.                 provided the example with 2 controllers hosting 2 devices
  845.  
  846.     Pierre Pfister <pp@uplift.fr>
  847.         helped to develop the recipe on 1:1 copies.
  848.  
  849.     Stephan Noy <stnoy@mi.uni-koeln.de>
  850.         information and experience about writing audio-CDs
  851.  
  852.     Stephen Harris <sweh@mpn.com>
  853.         contributed hint about writing audio-CDs
  854.  
  855.         The Sheepy One <kero@escape.com>
  856.                 suggested using defective CDs as coasters for drinks
  857.  
  858.         Volker Kuhlmann <kuhlmav@elec.canterbury.ac.nz>
  859.                 noticed that the "cdwrite"-package does not contain
  860.                 "mkisofs"
  861.  
  862. End of the Linux CD-Writing mini-HOWTO
  863.  
  864.